<template>
	<view class="container">
		<!-- <button class="button" type="default" @click="openTorch">打开闪光灯</button> -->
		<!-- <button class="button" type="default" @click="closeTorch">关闭闪光灯</button> -->
		<!-- <button class="button" type="default" @click="triggerTorch">触发打开闪光灯，三秒之后关闭</button> -->
		<view class="uni-form-item uni-column">
			<view>输入倒计时：</view>
			<id="count" input focus placeholder="请输入倒计时" v-model="countDown"/>
			<button @click="openTorch">确定</button>
		</view>
		<view class="count-down">
			{{ countDown }}
		</view>
		<view class="iconfont icon-kaiguan">			
		</view>
		<view class="iconfont icon-naozhong">					
		</view>		
		<view class="iconfont icon-time">
		</view>
		
	</view>
</template>

<script>
import torch from 'js_sdk/dc-torch/torch.js';

export default {
	data() {
		return {
			torchStatus: false,
			countDown: 0
		};
	},
	methods: {
		openTorch:function () {
			// torch.on();
			console.log("torch.on")
			let timerId = setInterval(() => {				
				this.countDown --
				if(this.countDown < 0){					
					clearInterval(timerId)
					console.log("torch.off")
					// torch.off()
				}
			},1000)
		}
		// closeTorch() {			
		// 	setTimeout(() => {
		// 		console.log(this.countDown)
		// 		torch.off()
		// 	}, this.countDown);			
		// },
		// triggerTorch() {
		// 	const delay = 4000
		// 	torch.on();
		// 	setTimeout(() => {				
		// 		torch.off()
		// 	}, this.countDown);
		// },
		// setCountDown(value) {
		// 	console.log(value)
		// }
	}
};
</script>

<style>
.container {
	padding: 20px;
	font-size: 14px;
	line-height: 24px;
}
.count-down {
	display: inline-block;
	width: 100%;
	height: 750rpx;
	line-height: 750rpx;
	text-align: center;
	font-size: 60rpx;	
}

.icon-font1 {
	font-family: ;
	src: url("~@/static/fonts/iconfont.css")
}

#button {
	border-radius: 10rpx;
}
</style>
